package com.goods.tool;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result<T> {
    private int success;
    private String msg;
    private int totalItems; // 请求成功的总条目数
    private T[] data;

    //成功但不携带数据
    public static <T> Result<T> success(){
        return new Result<>(1,"成功",0,null);
    }

    //成功携带数据
    public static <T> Result<T> success(T[] data,int totalItems){
        return new Result<>(1,"成功",totalItems,data);
    }

    //请求失败
    public static <T> Result<T> error(String msg){
        return new Result<>(0,msg,0,null);
    }
}
